import 'package:flutter/material.dart';
import 'package:huajianshe_app/base/AppNavigator.dart';
import 'package:huajianshe_app/common/AppRouter.dart';
import 'package:huajianshe_app/common/load_image.dart';
import 'package:huajianshe_app/common/res.dart';
import 'package:huajianshe_app/pages/lesson/model/LessonModel.dart';
import 'package:huajianshe_app/widget/RoundedCornerWidget.dart';

class LessonItem extends StatelessWidget {

  final Lesson? lesson;

  const LessonItem(this.lesson, {Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    print('111');
    return
      InkWell(onTap: () => { detail(context) },
          child: RoundedCornerWidget(child: Column(mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [
            lesson?.status == 1 ?
              RoundedCornerWidget(child: Center(child: Text('限时抢购', style: TS(10, Colors.white))), backgroundColor: C.orange,
                width: 54, height: 16, radius: 8, cornerPosition: 5, borderWidth: 0,
              ) : H(4),
            H(8),
            IntrinsicHeight(child:
            Row(children: [
              W(13),
              Expanded(child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
                SizedBox(height: 40, child:
                  Text(lesson?.name ?? '', style: TS(14, C.gray0D0E15), maxLines: 2, overflow: TextOverflow.ellipsis,),
                ),
                Text('共${lesson?.num}节|讲师:${lesson?.teacher}', style: TS(12, C.gray999), maxLines: 1, overflow: TextOverflow.ellipsis),
                Spacer(),
                Text('¥${lesson?.price}', style: TS(15, C.primary),)
              ])),
              W(20),
              Stack(children: [
                ClipRRect(borderRadius: BorderRadius.circular(3),
                    child: LoadImage(lesson?.cover, width: 100, height: 100),
                ),
                Positioned(child: RoundedCornerWidget(height: 18, radius: 9, backgroundColor: Color(0x88000000), padding: EdgeInsets.symmetric(horizontal: 6),
                    child: Row(mainAxisSize: MainAxisSize.min, children: [
                      LoadImage('ic_play_12'),
                      W(2),
                      Text('11:11:11', style: TS(11, Colors.white)) //todo 时长
                    ])
                ), bottom: 6,)
              ]),
              W(13)
            ])),
            H(12)
          ]), backgroundColor: Colors.white, borderWidth: 0, radius: 6,
          boxShadowList: [
            BoxShadow(color: Color.fromRGBO(0, 0, 0, 0.09), blurRadius: 6.5)
          ])
      );
  }

  detail(BuildContext context) {
    AppNavigator.push(context, RouteName.LESSON_DETAIL, arguments: {'id': lesson?.id});
  }
}